package javazuoye.one;



/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/06/26 23:53
 */
public class _2_2_10 {
    static class Node{
        int val;
        Node next;

        public Node() {
        }

        public Node(int val) {
            this.val = val;
        }
    }
    public static void main(String[] args) {
        Node node = new Node(1);
        node.next = new Node(2);
        node.next.next = new Node(2);
        node.next.next.next = new Node(3);
        node.next.next.next.next = new Node(3);
        node.next.next.next.next.next = new Node(4);
        node.next.next.next.next.next.next = new Node(4);
        node.next.next.next.next.next.next.next = new Node(4);
        node.next.next.next.next.next.next.next.next = new Node(4);
        node.next.next.next.next.next.next.next.next.next = new Node(4);
        quchong(node);
        while (node!=null){
            System.out.println(node.val);
            node = node.next;
        }
    }
    public static Node quchong(Node head){
        Node res = new Node(0);
        res.next = head;
        Node deep = res.next;
        while (deep.next!=null){
            if (deep.val==deep.next.val){
                deep.next = deep.next.next;
            }else {
                deep = deep.next;
            }
        }
        return res.next;
    }
}
